import type { PageParam, PageResult } from '@vben/request';
import type { Dayjs } from 'dayjs';

import { requestClient } from '#/api/request';

export namespace RechargeOrderApi {
  /** 充值订单信息 */
  export interface RechargeOrder {
    id: number; // 主键
    memberId: number; // 会员id
    activityId: number; // 活动id
    amount: number; // 充值价格
    giftAmount: number; // 赠送金额
    paymentMethod: number; // 支付方式
    completeTime: string | Dayjs; // 完成时间
    ipAddress: string; // 用户ip地址
    status?: number; // 服务状态
  }
}

/** 查询充值订单分页 */
export function getRechargeOrderPage(params: PageParam) {
  return requestClient.get<PageResult<RechargeOrderApi.RechargeOrder>>('/reservation/recharge-order/page', { params });
}

/** 查询充值订单详情 */
export function getRechargeOrder(id: number) {
  return requestClient.get<RechargeOrderApi.RechargeOrder>(`/reservation/recharge-order/get?id=${id}`);
}

/** 新增充值订单 */
export function createRechargeOrder(data: RechargeOrderApi.RechargeOrder) {
  return requestClient.post('/reservation/recharge-order/create', data);
}

/** 修改充值订单 */
export function updateRechargeOrder(data: RechargeOrderApi.RechargeOrder) {
  return requestClient.put('/reservation/recharge-order/update', data);
}

/** 删除充值订单 */
export function deleteRechargeOrder(id: number) {
  return requestClient.delete(`/reservation/recharge-order/delete?id=${id}`);
}

/** 导出充值订单 */
export function exportRechargeOrder(params: any) {
  return requestClient.download('/reservation/recharge-order/export-excel', params);
}

